package slu.appli.wodtimer.swing2.adapter;

import javax.swing.SwingUtilities;

import slu.appli.wodtimer.info.WodTimerInformation;
import slu.appli.wodtimer.info.WodTimerInformationListenerInterface;

public abstract class WodTimerInformationListener4Swing
implements WodTimerInformationListenerInterface {

	@Override
	public void WodTimerChanged(WodTimerInformation infos) {
		if (SwingUtilities.isEventDispatchThread()) {
			this.process(infos);
		}
		else {
			SwingUtilities.invokeLater(new InnerRunnable(infos));
		}
	}
	
	private class InnerRunnable implements Runnable {
		private final WodTimerInformation infos;

		public InnerRunnable(WodTimerInformation infos) {
			super();
			this.infos = infos;
		}

		@Override
		public void run() {
			WodTimerInformationListener4Swing.this.process(this.infos);
		}
		
	}
	
	protected abstract void process(WodTimerInformation infos);

}
